package route

import "net/http"

type RouteHandler interface {
	WebSocketHandler(w http.ResponseWriter, req *http.Request)

	RPCServiceListHandler(w http.ResponseWriter, req *http.Request)
	QPSInfoHandler(w http.ResponseWriter, req *http.Request)

	OWLServiceListHandler(w http.ResponseWriter, req *http.Request)
	LogInfoHandler(w http.ResponseWriter, req *http.Request)
	QueryLogHandler(w http.ResponseWriter, req *http.Request)

	IndexHandler(w http.ResponseWriter, req *http.Request)
	GetTokenHandler(w http.ResponseWriter, req *http.Request)
}

func New(handler RouteHandler) *http.ServeMux {
	mux := http.NewServeMux()
	mux.HandleFunc("/websocket", handler.WebSocketHandler)

	mux.HandleFunc("/services", handler.RPCServiceListHandler)
	mux.HandleFunc("/info", handler.QPSInfoHandler)

	mux.HandleFunc("/owl/detail/log", handler.LogInfoHandler)
	mux.HandleFunc("/owl/query/log", handler.QueryLogHandler)
	mux.HandleFunc("/owl/services", handler.OWLServiceListHandler)

	mux.HandleFunc("/token", handler.GetTokenHandler)
	mux.HandleFunc("/home", handler.IndexHandler)

	return mux
}
